/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bm.util;

import com.bm.setting.ServerConfig;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author ssm
 */
public class DBUtil {
    public static long getLongSeq(String seq_name){
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        try
        {
            String qry = "select nextval('"+seq_name+"') as seq_value";
            conn = ServerConfig.getConnection();
            stmt = conn.createStatement();
            rs = stmt.executeQuery(qry);
            while (rs.next())
            {
                return rs.getLong("seq_value");
            }
        }
        catch (SQLException ex)
        {
            MessagePrinter.printDebug(ex.getMessage());
        }
        finally
        {
            ServerConfig.close(rs);
            ServerConfig.close(stmt);            
            ServerConfig.close(conn);            
        }
        return 0;
    }
}
